<?php
class StudenteController extends AppController {
    // var $helpers = array ('Html','Form');
    //errore:var $name = 'Pages'; // riferimento alla cartella delle view
    
    public function beforeFilter(){
    	
		parent::beforeFilter();
        $this->Auth->allow('index','view','setelem','remove');
		
		
    }
    
    public function index() {
       // pr($this->Studente->find('all'));die;
    }
	
	public function view($idStudente=''){
	}
	
	
	public function remove($idStudente,$idClasse)
	{
		$this->Studente->read(null,$idStudente);
		$this->Studente->set('classe_id',null);
		$this->Studente->save();
		$this->Session->setFlash(__("Studente rimosso con successo!"));	   
		$this->redirect(array('controller' => 'classe', 'action' => 'view',$idClasse));
	}
	
	
	public function setelem()
	{
		$idClasse = $this->request->data['Classe']['id'];
		$this->Studente->read(null,$this->request->data['Studente']['id']);
		$this->Studente->set('classe_id',$idClasse);
		$this->Studente->save();
		$this->Session->setFlash(__("Studente associato con successo!"));	   
		$this->redirect(array('controller' => 'classe', 'action' => 'view',$idClasse));
	}
	
		

}
?>